<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
    <head>
        <meta charset="utf-8"/>
        <title>rater Hello World!</title>
    </head>
    <body>
     <p>rater</p>
     
     	<a href="http://127.0.0.1:8080/grade/getimg?id=1">获取照片</a> 
     
      <button  onclick="getMe()">获取本人信息</button>
       <button  onclick="getNext()">获取下一个打分人</button> 
        <button  onclick="score()">打分</button>
        
         <button  onclick="allScore()">阶段所有打分</button>
         
           <button  onclick="commit()">提交打分</button>
       
       <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
			<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
			<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
			<script src="../js/ip.js"></script> 
        <script type="text/javascript">
        
        
        
        var stageId = 1;
        var sort = 0;
        var scoreInfoId = 1;
        function getMe() { 
			var postaddress = '/current'; 
			var sendData = new Object();
			sendData.scoreInfoId = scoreInfoId;
			sendData.sort = sort;
			$.ajax({
				//几个参数需要注意一下
				type: "get", //方法类型
				dataType: "json", //预期服务器返回的数据类型
				url: postaddress, //url 
				success: function(result) {
					console.log(result); //打印服务端返回的数据 
					if (result.code == 0)
					{
						alert(result.data.name);
					} else
						{ 
						alert("错误"); 
						}
				}, 
				error: function() {

				}
			});
		}
    	function getNext() { 
			var postaddress = '/grade/next'; 
			var info = new Object();
			info.scoreInfoId = 1;
			info.sort = sort;
			info.stageId = 1;
			console.log(JSON.stringify(info));
			$.ajax({
				//几个参数需要注意一下
				type: "POST", //方法类型
				dataType: "json", //预期服务器返回的数据类型
				contentType: "application/json;charset=utf-8",
				url: postaddress, //url
				data: JSON.stringify(info),
				success: function(result) {
					console.log(result); //打印服务端返回的数据 
					if (result.code == 0)
					{
						alert(result.data.candidateName +"_" +result.data.candidateId);
						sort = info.sort + 1;
					} 
				}, 
				error: function() { 
						alert("错误");  
				}
			});
		}
        
				function score() { 
					var info = new Object();
					info.scoreInfoId = 1;
					info.stageId = stageId;
					info.sort = sort;
					info.candidateId = 1;
					info.fraction = 90;
					console.log(JSON.stringify(info));
					var postaddress = '/grade/set';
					console.log(JSON.stringify(info));
					$.ajax({
						//几个参数需要注意一下
						type: "POST", //方法类型
						dataType: "json", //预期服务器返回的数据类型
						contentType: "application/json;charset=utf-8",
						url: postaddress, //url
						data: JSON.stringify(info) ,
						success: function(result) {
							console.log(result); //打印服务端返回的数据 
							if (result.code == 0)
							{
								alert(result.data.candidateId);
							} 
						}, 
						error: function() {
							alert(result.msg);
						}
					});
				}
				
				function allScore() { 
					var info = new Object(); 
					info.stageId = stageId; 
					console.log(JSON.stringify(info));
					var postaddress = '/grade/getall';
					console.log(JSON.stringify(info));
					$.ajax({
						//几个参数需要注意一下
						type: "POST", //方法类型
						dataType: "json", //预期服务器返回的数据类型
						contentType: "application/json;charset=utf-8",
						url: postaddress, //url
						data: JSON.stringify(info) ,
						success: function(result) {
							console.log(result); //打印服务端返回的数据 
							if (result.code == 0)
							{
								alert(result.data);
							} 
						}, 
						error: function() {
							alert(result.msg);
						}
					});
				}
				
				
				function commit() { 
					var info = new Object(); 
					info.stageId = stageId; 
					console.log(JSON.stringify(info));
					var postaddress = '/grade/commit';
					console.log(JSON.stringify(info));
					$.ajax({
						//几个参数需要注意一下
						type: "POST", //方法类型
						dataType: "json", //预期服务器返回的数据类型
						contentType: "application/json;charset=utf-8",
						url: postaddress, //url
						data: JSON.stringify(info) ,
						success: function(result) {
							console.log(result); //打印服务端返回的数据 
							if (result.code == 0)
							{
								alert(result.data);
							} 
						}, 
						error: function() {
							alert(result.msg);
						}
					});
				}
				
			</script> 
    </body>
</html>